const { con,Result } = require('./common.js');

let login = async (email,password) => {
  let res = new Result();

  let sql = `select * from users where email = '${email}'`;
  let [rows] = await con.execute(sql);

  if(rows.length === 0){
    res.code = 40101;
    res.msg  = 'user not exist';
  }else if(rows[0].password !== password){
    res.code = 40102;
    res.msg  = 'password error';
  }else{
    //ok   会有默认值
  }


  return res;
};

module.exports = { login };
